package geometric3D;

public class zLineSegment extends LineSegment {


	public zLineSegment() {
		super();
	}
	
	
	
	public zLineSegment(Point startPoint, int length,
			boolean isPositiveProjected) {
		if(isPositiveProjected){
			this.startPoint = startPoint;
			this.endPoint = new Point(startPoint.getX(), 
					startPoint.getY(), startPoint.getZ()+length);
			
		}else{
			this.startPoint = new Point(startPoint.getX(), 
					startPoint.getY(), startPoint.getZ()-length);
			this.endPoint = startPoint;
		}

	}

	public zLineSegment(Point startPoint, Point endPoint) {
		if(startPoint.getZ() >endPoint.getZ()){
			this.startPoint = endPoint;
			this.endPoint =startPoint;
			
		}else{
			this.startPoint = startPoint;
			this.endPoint =endPoint;
		}
		length = Math.abs(endPoint.getZ()-startPoint.getZ());
	}

	@Override
	public Point getEndPoint() {
		return this.endPoint;
	}

	@Override
	public Point getStartPoint() {

		return this.startPoint;
	}



	@Override
	public String toString() {
		return "zLineSegment [startPoint=" + startPoint + ", endPoint="
				+ endPoint + ", length=" + length + "]";
	}
	
	@Override
	public boolean isInLineSegment(Point point) {
		if(point.getY() != startPoint.getY() 
				|| point.getX() != startPoint.getX()
				|| point.getZ() < startPoint.getZ()
				|| point.getZ()> endPoint.getZ()){
			return false;
		}
		return true;
	}
	
}
